// import express from 'express';
// import mongoose from 'mongoose';
// import routes from './routes';

// const app = express();
// const port = 3000;

// app.use(express.json());
// app.use(routes);

// mongoose.connect('mongodb://localhost:27017/mydatabase', {
// //   useNewUrlParser: true,
// //   useUnifiedTopology: true
// }).then(() => {
//   console.log('Connected to MongoDB');
// }).catch((error) => {
//   console.error('Error connecting to MongoDB:', error.message);
// });

// app.listen(port, () => {
//   console.log(`Server running on port ${port}`);
// });



import express from 'express';
import bodyParser from 'body-parser';
import { sequelize } from './model/models';
import router from './router/router';

const app = express();

app.use(bodyParser.json());
app.use(router);

const startServer = async () => {
  try {
    await sequelize.sync();
    app.listen(3000, () => {
      console.log('Server is running on port 3000');
    });
  } catch (error) {
    console.error('Error starting server:', error);
  }
};

startServer();
